import Vue from 'vue'
import App from './App.vue'
import './assets/css/gloable.css'
// 引入编辑面板
import VueQuillEditor from 'vue-quill-editor'
// 引入编辑面板样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
//引入路由模块
import VueRouter from 'vue-router'
import router from './router/index.js'
// 引入ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';


//引入字体图标
import './assets/fonts/iconfont.css';

import treeTable from 'vue-table-with-tree-grid'

//引入axios用于发起请求
import axios from 'axios'



//将axios挂在在vue的原型对象上，让每一个组件都能使用它
Vue.prototype.$http = axios;
//配置请求拦截器，让需要授权的api（后端接口）可以被调用
axios.interceptors.request.use((config) => {
    //设置了一个请求头，给其添加了一个参数Authorization（授权）
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
})

Vue.use(ElementUI);
Vue.use(VueRouter);
// 全局时间过滤器
Vue.filter('dateFormat', function(originVal) {
    const dt = new Date(originVal)

    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + 1 + '').padStart(2, '0')
    const hh = (dt.getHours() + 1 + '').padStart(2, '0')
    const mm = (dt.getMinutes() + 1 + '').padStart(2, '0')
    const ss = (dt.getSeconds() + 1 + '').padStart(2, '0')
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.component('tree-table', treeTable)
    // 将文本编辑器注册为全局组件
Vue.use(VueQuillEditor)

Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App),
}).$mount('#app')